
/** 
 * @fileoverview 
 *  Author:			zhangxin<BR>
 *  Created:		2007-05-16 11:08<BR>
 *  Vesion:			1.0<BR>
 *  Last EditTime:	<BR>
 *	Depends:<BR>
 *		
 *<BR>
 *	Examples:<BR>
 *		@see Toolkit_test.html<BR>
 * @author ppl
 * @version 1.o
 */
/**
 * 当_aVar为null时返回为true,否则返回为false
 * @param _aVar : 待检测参数 
 */
function isNull(_aVar) {
	return ((typeof (_aVar) == "undefined") || _aVar == null) ? true : false;
}
/**
 * 当_obj为null时,返回_defaultValue,否则返回_obj
 * @param _obj : 待检测的值
 * @param _defaultValue : 默认值
 */
function dealNull(_obj, _defaultValue) {
	return isNull(_obj) ? _defaultValue : _obj;
}
/**
 * 打开新页面
 * @param _url : 要打开的地址
 * @param isModalDialog : 是否要以模态窗口showModalDialog的形式打开, 还是windows.open()形式打开
 * @param wp : 宽度百分比
 * @param hp : 高度百分比
 * @param top : Y坐标 
 * @param left ：X坐标
 * @param _target ：此属性只针对于 使用 window.open()方法 
 */
function openNewPage(_url, isModalDialog, wp, hp, _top, _left, _target, _center) {
	isModalDialog = dealNull(isModalDialog, true);
	_center = dealNull(_center, true);
	wp = dealNull(wp, 1);
	hp = dealNull(hp, 1);
	var w = window.screen.width * wp;
	var h = window.screen.height * hp;
	if (_center) {
		_left = (window.screen.width * (1 - wp) * 0.5);
		_top = (window.screen.height * (1 - hp) * 0.5);
	} else {
		_left = dealNull(_left, (window.screen.width * (1 - wp) * 0.5));
		_top = dealNull(_top, (window.screen.height * (1 - hp) * 0.5));
	}
	if (isModalDialog) {
		_target = dealNull(_target, window);
		//增加一个随机数，保证每次打开都是一个新的窗口
		if (_url.indexOf("?") != -1) {
			_url = _url + "&__freshRandomId=" + new Date().toString();
		} else {
			_url = _url + "?__freshRandomId=" + new Date().toString();
		}
		window.showModalDialog(_url, _target, "status:false;dialogWidth:" + w + "px;dialogHeight:" + h + "px;dialogTop=" + _top + ";dialogLeft=" + _left);
	} else {
		window.open(_url, _target, "height=" + h + ",width=" + w + ",top=" + _top + ",left=" + _left + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no, status=no");
	}
}

/**
 * 刷新父页面并关闭子页面
 */
function closeAndReloadParent() {
	try {
		dialogArguments.document.location.href = dialogArguments.document.location.href;
		window.close();
	}
	catch (e) {
		try {
			window.opener.document.location.href = window.opener.document.location.href;
			window.close();
		}
		catch (e) {
			window.close();
		}
	}
}

/**
 * 刷新左边的iframe页面
 */
function refreshLeftPage() {
	window.parent.document.frames[0].document.location.href = window.parent.document.frames[0].document.location.href;
}
/**
 * 鼠标起始横坐标
 */
function getX() {
	return document.body.scrollLeft + event.clientX;
}
/**
 * 鼠标起始纵坐标
 */
function getY() {
	return document.body.scrollLeft + event.clientY;
}

//----------------------------------------------------------------------------------------------//
//                                      String  Util  start										//
//----------------------------------------------------------------------------------------------//
/**
 * Returns a copy of the string, with leading and trailing whitespace omitted. 
 */
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g, "");
}
/**
 * 判断对象(String)是否为空
 */
function isBlank(_obj) {
	return isNull(_obj) ? true : (trim(_obj.toString()) == "");
}
/**
 * Returns a copy of the string, with leading whitespace omitted. 
 */
function ltrim(s) {
	return stringToTrim.replace(/^\s+/, "");
}
/**
 * Returns a copy of the string, with trailing whitespace omitted. 
 */
function rtrim(s) {
	return stringToTrim.replace(/\s+$/, "");
}
//----------------------------------------------------------------------------------------------//
//                                      String  Util end										//
//----------------------------------------------------------------------------------------------//

			
//----------------------------------------------------------------------------------------------//
//                                      DHtml 对象 属性 操作 相关 	start							//
//----------------------------------------------------------------------------------------------//
/**
 *	@param _dObj : DHTML object 对象(table,form,div...支持getElementsByTagName方法的对象(必选项)
 *  @param  _tagName : tag name ('input','textarea') or  tag name array ( new Array('input','textarea'))(必选项)
 */
function getSTagNameCollObjects(_dObj, _tagName) {
	if (_tagName instanceof Array) {
		var col = new Array();
		var _tagNameLen = _tagName.length;
		var aCol = {};
		for (var n = 0; n < _tagNameLen; n++) {
			aCol = _dObj.getElementsByTagName(_tagName[n] + "");
			var len = aCol.length;
			for (var j = 0; j < len; j++) {
				col.push(aCol[j]);
			}
		}
		return col;
	} else {
		return _dObj.getElementsByTagName(_tagName + "");
	}
}
/**
 *  @param  _elementIds : 　(必选项)　一个 Array 对象　　如：( new Array('a_Id','b_Id','c_Id')),或是一个字符串(一个对象的ID) 'a_id'    
 *	@param _dObj :　 (可选项)　DHTML object 对象(table,form,div...支持getElementById方法的对象)    
 *  add by zx at 2007.07.30
 *  update 07.08.02
 */
function getCollObjectsByIds(_elementIds, _dObj) {
	var col = new Array();
	if (isNull(_dObj)) {
		_dObj = window.document;
	}
	if (isNull(_elementIds)) {
		return col;
	}
	if (_elementIds instanceof Array) {
		var _elementIdsLen = _elementIds.length;
		for (var n = 0; n < _elementIdsLen; n++) {
			if (!isBlank(_elementIds[n])) {
				var obj = _dObj.getElementById(_elementIds[n] + "");
				if (!isNull(obj)) {
					col.push(obj);
				}
			}
		}
	} else {
		var obj = _dObj.getElementById(_elementIds + "");
		if (!isNull(obj)) {
			col.push(obj);
		}
	}
	return col;
}
/**
 * 设置对象属性父类
 */
function SetProperty() {
	this.execute = function (_obj) {
	};
}
/**
 * 设置对象为只读属性
 */
function SetObjectReadOnly() {
	this.execute = function (_obj) {
		_obj.readOnly = true;
		_obj.onbeforeactivate = function () {
			return false;
		};
		_obj.onfocus = function () {
			this.blur();
		};
		_obj.onmouseover = function () {
			this.setCapture();
		};
		_obj.onmouseout = function () {
			this.releaseCapture();
		};
		_obj.oncontrolselect = function () {
		};
	};
}
SetObjectReadOnly.prototype = new SetProperty();
//alert('new SetObjectReadOnly() instanceof SetProperty = '+(new SetObjectReadOnly() instanceof SetProperty));		
/**
 * 设置对象disabled为true
 */
function SetObjectDisabled(_obj) {
	this.execute = function (_obj) {
		_obj.disabled = true;
	};
}
SetObjectDisabled.prototype = new SetProperty();
//alert('new SetObjectDisabled() instanceof SetProperty = '+(new SetObjectDisabled() instanceof SetProperty));	
/**
 * 设置对象disabled为false
 */
function SetObjectEnabled(_obj) {
	this.execute = function (_obj) {
		_obj.disabled = false;
	};
}
SetObjectEnabled.prototype = new SetProperty();
/**
 * 设置对象为不可见(隐藏)
 */
function SetObjectHidden(_obj) {
	this.execute = function (_obj) {
		_obj.style.display = "none";
	};
}
SetObjectHidden.prototype = new SetProperty();
/**
 * 设置对象为可见(显示)
 */
function SetObjectShow(_obj) {
	this.execute = function (_obj) {
		_obj.style.display = "inline";
	};
}
SetObjectShow.prototype = new SetProperty();
/**
 * 设置对象只能被输入正整数
 */
function SetInputIntegerOnly(_obj) {
	this.execute = function (_obj) {
		_obj.onkeyup = function () {
			this.value = this.value.replace(/[^\d]/g, "");
		};
	};
}
SetInputIntegerOnly.prototype = new SetProperty();
/**
 * 设置对象只能被输入double(不完善)
 */
function SetInputDoubleOnly(_obj) {
	this.execute = function (_obj) {
		_obj.onkeyup = function () {
			this.value = this.value.replace(/[^\.\d]/g, "");
		};
	};
}
SetInputDoubleOnly.prototype = new SetProperty();
/**
 * 批量设置对象属性
 * @param _objectArray : 对象数组()(必选项)
 * @param _methodObj : 要调用的方法对象(SetProperty的子类)(必选项)
 */
function setObjectsProperty(_objectArray, _methodObj) {
	var len = _objectArray.length;
	for (var n = len - 1; n > -1; n--) {
		_methodObj.execute(_objectArray[n]);
	}
}
//----------------------------------------------------------------------------------------------//
//                                      DHtml 对象 属性 操作 相关 	end								//
//----------------------------------------------------------------------------------------------//


//----------------------------------------------------------------------------------------------//
//                                      日期处理方法 start 						                //
//----------------------------------------------------------------------------------------------//
/**
 * 判断对象是否日期类型
 */
function isDate(obj) {
	return obj instanceof Date;
}
/**
 * 比较两个日期的大小
 * 返回说明：
 * 1 如果date1比date2大
 * 0 如果date1和date2相等
 * -1 如果date1比date2小
 */
function dateCompare(date1, date2) {
	if (!(isDate(date2) || isDate(date1))) {
		// throw '不是日期类型';
		if (date1 > date2) {
			return 1;
		} else {
			if (date1 < date2) {
				return -1;
			} else {
				if (date1 == date2) {
					return 0;
				}
			}
		}
	}
	var diff = date1.getTime() - date2.getTime();
	if (diff > 0) {//date1 is after date2 
		return 1;
	} else {
		if (diff < 0) {//date1 is before date2
			return -1;
		} else {//date1 equals date2
			return 0;
		}
	}
}

/**
 * 字符串转换成时间
 * str : 时间字符串以'-'隔开
 */
function strToDate(str) {
	var arys = new Array();
	arys = str.split("-");
	var newDate = new Date(arys[0], arys[1], arys[2]);
	return newDate;
}

/**字符串转换成时间*/
function strToDate(str) {
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
	var r = str.match(reg);
	if (r == null) {
		return false;
	}
	var newDate = new Date(r[1], --r[3], r[4]);
	return newDate;
}

/**字符串转换成时间*/
function strToDateTime(str) {
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2})$/;
	var r = str.match(reg);
	if (r == null) {
		return false;
	}
	var newDate = new Date(r[1], --r[3], r[4], r[5], r[6]);
	return newDate;
}
//----------------------------------------------------------------------------------------------//
//                                      日期处理方法 end						                    //
//----------------------------------------------------------------------------------------------//


//----------------------------------------------------------------------------------------------//
//                                      Ajax异步、同步请求方法封装 start 						    //
//----------------------------------------------------------------------------------------------//

/**
 * 初始化XMLHttpRequest对象
 * 
 * @return
 */
function initXmlHttp() {
	//XMLHttpRequest对象
	var xmlHttp = false;
	if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) { // IE6及其以下的IE版本
			var activeXNames = ["MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
			for (var i = 0; i < activeXNames.length; i++) {
				try {
					xmlHttp = new ActiveXObject(activeXNames[i]);
					break;
				}
				catch (e) {
				}
			}
		}
	}
	if (!xmlHttp) {
		alert("\u65e0\u6cd5\u83b7\u53d6XMLHttpRequest, \u4f60\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301Ajax");
	}
	return xmlHttp;
}

/**
 * @param url
 *            要访问的路径
 * @param data
 *            要传送的数据
 * @param callback
 *            回调函数
 * @param responseContentType
 *            响应内容的类型，支持3种类型："TEXT","XML","JSON", 没有时自动判断, 
 *            可选，若不输入时，则会根据返回的值字符串作判断
 * @param asyn
 * 		      执行方式，支持2种方式：true(异步), false(同步)
 * 			  可选, 若不输入时，默认用异步方式执行
 */
function doGet(url, data, responseFunction, responseContentType, asyn) {
	if (asyn == undefined) {
		if (responseContentType != undefined) {
			if (typeof responseContentType == "boolean") {
				asyn = responseContentType;
			}
		}
	}
	var url = url;
	if (data != null && data != "") {
		if (url.indexOf("?") == -1) {
			url = url + "?" + data;
		} else {
			url = url + "&" + data;
		}
	}
	var xmlHttp = initXmlHttp();
	xmlHttp.onreadystatechange = function () {
		callbackAjax(responseFunction, responseContentType, xmlHttp);
	};
	if (asyn == undefined) {
		xmlHttp.open("GET", url, true);
	} else {
		if (asyn == false) {
			xmlHttp.open("GET", url, false);
		} else {
			xmlHttp.open("GET", url, true);
		}
	}
	xmlHttp.send(null);
}
/**
 * 
 * @param url
 * @param data
 *            格式1："key1=value1&key2=value2"
 *            (Server端，通过request.getParameter(key)可取值)
 *            格式2：{"key1":"value1","key2":"value2"}，即JSON.stringify(jsonObj)得到的JSON格式字符串,
 *            Server端，通过request.getReader().read();读取出来 格式3：XML
 * @param callback
 * @param responseContentType
 *            响应内容的类型，支持3种类型："TEXT","XML","JSON", 没有时自动判断, 
 *            可选，若不输入时，则会根据返回的值字符串作判断
 * @param asyn
 * 		      执行方式，支持2种方式：true(异步), false(同步)
 * 			  可选, 若不输入时，默认用异步方式执行
 */
function doPost(url, data, responseFunction, responseContentType, asyn) {
	if (asyn == undefined) {
		if (responseContentType != undefined) {
			if (typeof responseContentType == "boolean") {
				asyn = responseContentType;
			}
		}
	}
	var xmlHttp = initXmlHttp();
	xmlHttp.onreadystatechange = function () {
		callbackAjax(responseFunction, responseContentType, xmlHttp);
	};
	if (asyn == undefined) {
		xmlHttp.open("POST", url, true);
	} else {
		if (asyn == false) {
			xmlHttp.open("POST", url, false);
		} else {
			xmlHttp.open("POST", url, true);
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send(data);
}
/**
 * Ajax回调函数
 * @param responseFunction
 * @param responseContentType
 * @return
 */
function callbackAjax(responseFunction, responseContentType, xmlHttp) {
	// 判断对象的状态是否交互完成
	if (xmlHttp.readyState == 4) {
		// 判断http的交互是否成功
		if (xmlHttp.status == 200) {
			if (responseContentType == "XML") {
				var responseXml = xmlHttp.responseXML;
				responseFunction(responseXml);
			} else {
				var responseText = xmlHttp.responseText;
				if (responseContentType == "JSON") {
					var responseJson = eval("(" + responseText + ")");
					responseFunction(responseJson);
				} else {
					if (responseContentType == "TEXT") {
						responseFunction(responseText);
					} else {
					//没有responseContentType参数的情况
						if (responseText.indexOf("<") == 0) {
							var responseXml = xmlHttp.responseXML;
							responseFunction(responseXml);
						} else {
							if (responseText.indexOf("{") == 0 || responseText.indexOf("[") == 0) {
								var responseJson = eval("(" + responseText + ")");
								responseFunction(responseJson);
							} else {
								responseFunction(responseText);
							}
						}
					}
				}
			}
		}
	}
}
//----------------------------------------------------------------------------------------------//
//                                      Ajax异步、同步请求方法封装 end						        //
//----------------------------------------------------------------------------------------------//


//----------------------------------------------------------------------------------------------//
//  获取表单数据封装，一般用于获取多个表单数据，并组成url参数格式，比如username=tom&password=123            //
//  里面还包含一个Map类构造函数     start	                                                            //
//----------------------------------------------------------------------------------------------//

/**
 * 获取表单数据
 * 用法：
 * var data = getFormData("username", "password");
 * @return "username=tom&password=123"格式的字符串
 */
function getFormData() {
	var map = new ParamMap();
	var length = arguments.length;
	for (var i = 0; i < length; i++) {
		var nodeList = document.getElementsByName(arguments[i]);
		var values = nodeList2ValuesArray(nodeList);
		for (var j = 0; j < values.length; j++) {
			map.put(arguments[i], values[j]);
		}
	}
	return map.toString();
}

/**
 * 获取nodeList的值集
 * 
 * @param nodeList
 *            Node数组，可通过getElementsByName或者getElementsByTagName等方法获得
 * @return 值数组
 */
function nodeList2ValuesArray(nodeList) {
	var values = new Array();
	var length = nodeList.length;
	var nodeName = nodeList.item(0).nodeName;
	if (nodeName == "INPUT") {
		var type = nodeList.item(0).getAttribute("type");
		if (type == "text" || type == "password" || type == "hidden") {
			for (var i = 0; i < length; i++) {
				values.push(nodeList.item(i).value);
			}
		} else {
			if (type == "checkbox" || type == "radio") {
				for (var i = 0; i < length; i++) {
					var node = nodeList.item(i);
					if (node.checked) {
						values.push(node.value);
					}
				}
			}
		}
	} else {
		if (nodeName == "TEXTAREA") {
			for (var i = 0; i < length; i++) {
				values.push(nodeList.item(i).value);
			}
		} else {
			if (nodeName == "SELECT") {
				var subNodeList = nodeList.item(0).getElementsByTagName("option");
				return nodeList2ValuesArray(subNodeList);
			} else {
				if (nodeName == "OPTION") {
					for (var i = 0; i < length; i++) {
						var node = nodeList.item(i);
						if (node.selected) {
							values.push(node.value);
						}
					}
				}
			}
		}
	}
	return values;
}

/**
 * ParamMap类构造函数，继承Map类
 */
function ParamMap() {

	// 继承Map类
	Map.call(this);

	// 重写put方法，允许多个同名key存在
	this.put = function (key, value) {
		if (key == null || key == undefined) {
			return;
		}
		this.keys.push(key);
		this.values.push(value);
	};

	// 重写get方法，返回values数组
	this.get = function (key) {
		var results = new Array();
		var length = this.size();
		for (var i = 0; i < length; i++) {
			if (this.keys[i] == key) {
				results.push(this.values[i]);
			}
		}
		return results;
	};

	// 重写remove方法
	this.remove = function (key) {
		var length = this.size();
		for (var i = 0; i < length; i++) {
			if (this.keys[i] == key) {
				while (i < length - 1) {
					this.keys[i] = this.keys[i + 1];
					this.values[i] = this.values[i + 1];
					i++;
				}
				// 处理最后一个元素
				this.keys.pop();
				this.values.pop();
			}
		}
	};

	// 重写toString方法, 转成XMLHttpRequest.send(ajaxString)方法的参数格式的字符串
	this.toString = function () {
		var length = this.size();
		var str = "";
		for (var i = 0; i < length; i++) {
			str = str + this.keys[i] + "=" + this.values[i];
			if (i != length - 1) {
				str += "&";
			}
		}
		return str;
	};
}

/**
 * Map类构造函数
 */
function Map() {

	// key集
	this.keys = new Array();

	// value集
	this.values = new Array();

	// 添加key-value进Map
	this.put = function (key, value) {
		if (key == null || key == undefined) {
			return;
		}
		var length = this.size();
		for (var i = 0; i < length; i++) {
			// 如果keys数组中有相同的记录，则不保存重复记录
			if (this.keys[i] == key) {
				return;
			}
		}
		this.keys.push(key);
		this.values.push(value);
	};

	// 获取指定key的value
	this.get = function (key) {
		var length = this.size();
		for (var i = 0; i < length; i++) {
			if (this.keys[i] == key) {
				return this.values[i];
			} else {
				continue;
			}
			return null;
		}
	};

	// 移除指定key所对应的map
	this.remove = function (key) {
		var length = this.size();
		for (var i = 0; i < length; i++) {
			if (this.keys[i] == key) {
				while (i < length - 1) {
					this.keys[i] = this.keys[i + 1];
					this.values[i] = this.values[i + 1];
					i++;
				}
				// 处理最后一个元素
				this.keys.pop();
				this.values.pop();
				break;
			}
		}
	};

	// 是否包含指定的key
	this.containsKey = function (key) {
		var length = this.size();
		for (var i = 0; i < length; i++) {
			if (this.keys[i] == key) {
				return true;
			}
		}
		return false;
	};

	// 是否包含指定的value
	this.containsValue = function (value) {
		var length = this.size();
		for (var i = 0; i < length; i++) {
			if (this.values[i] == value) {
				return true;
			}
		}
		return false;
	};

	// 包含记录总数
	this.size = function () {
		return this.keys.length;
	};

	// 是否为空
	this.isEmpty = function () {
		return this.size() == 0 ? true : false;
	};

	// 清空Map
	this.clear = function () {
		this.keys = new Array();
		this.values = new Array();
	};

	// 打印map，格式：key1=value1,key2=value2
	this.toString = function () {
		var length = this.size();
		var str = "";
		for (var i = 0; i < length; i++) {
			str = str + this.keys[i] + "=" + this.values[i];
			if (i != length - 1) {
				str += ",";
			}
		}
		return str;
	};
}
//----------------------------------------------------------------------------------------------//
//  获取表单数据封装，一般用于获取多个表单数据，并组成url参数格式，比如username=tom&password=123            //
//  里面还包含一个Map方法封装     end	                                                            //
//----------------------------------------------------------------------------------------------//


//----------------------------------------------------------------------------------------------//
//                                      checkbox相关方法 start 									//
//----------------------------------------------------------------------------------------------//
//使得复选框成单选,为了界面的统一美观，建议都用复选框，可以通过此方法变成单选的
function changeCheckboxToRadio(checkboxObj) {
	var checkBoxs = document.getElementsByName(checkboxObj.name);
	if (checkboxObj.checked) {
		for (var i = 0; i < checkBoxs.length; i++) {
			if (checkBoxs[i] != checkboxObj) {
				checkBoxs[i].checked = false;
			}
		}
	}
}

/**
 * 切换复选框的选中状态
 * 使用示例：
 * <p>在列表页th中的checkbox：<br/>
 * <code>
 * &lt;input type="checkbox" onclick="checkAllCheckbox(this,'checkObjId');" /&gt;
 * </code>
 * </p>
 * <p>在列表页td中的checkbox: <br/>
 * <code>
 * &lt;input type="checkbox" name="checkObjId" value="&lt;ww:property value='id'/&gt;" /&gt;
 * </code>
 * </p>
 * @param hitCheckbox 被点击的Checkbox对象
 * @param checkboxName 列表中checkbox的name
 */
function checkAllCheckbox(hitCheckbox, checkboxName) {
	var checkboxs = document.getElementsByName(checkboxName);
	if (checkboxs.length > 0) {
		for (var i = 0; i < checkboxs.length; i++) {
			checkboxs[i].checked = hitCheckbox.checked;
		}
	}
}
/**
 * 获取复选框的值字符串
 * @param checkboxName 列表中checkbox的name
 * @return 值字符串，以","号隔开,如"12,13,16"
 */
function getAllCheckedValues(checkboxName) {
	var checkboxs = document.getElementsByName(checkboxName);
	if (checkboxs.length <= 0) {
		return "";
	} else {
		var idArray = new Array();
		for (var i = 0; i < checkboxs.length; i++) {
			if (checkboxs[i].checked) {
				idArray.push(checkboxs[i].value);
			}
		}
		return idArray.join(",");
	}
}

/**
 * 有待于改进
 * 1. 不用再在check all 的checkbox input 中 加 state = false的硬编码
 * 2. 当一个页面中有多个list列表时,此方法的缺陷
 */
function checkAll(checkAllObj) {
	var inputArr = window.document.getElementsByTagName("input");
	if (isNull(checkAllObj.state)) {
		checkAllObj.state = new Boolean(false);
	}
	var checkState = checkAllObj.state;
	checkAllObj.state = !checkAllObj.state;
	for (var i = 0; i < inputArr.length; i++) {
		if (inputArr[i].type == "checkbox") {
			inputArr[i].checked = checkState;
		}
	}
}

//根据chockbox的name返回第一个被选中的值，一般用于chockbox做单选的情况取选中的值
function getCheckboxFirstSelectedValue(checkboxName) {
	var checkBoxs = document.getElementsByName(checkboxName);
	for (var i = 0; i < checkBoxs.length; i++) {
		if (checkBoxs[i].checked == true) {
			return checkBoxs[i].value;
		}
	}
	return null;
}
//----------------------------------------------------------------------------------------------//
//                                      checkbox相关方法 end 									    //
//----------------------------------------------------------------------------------------------//


//计算字符串字节数,可用于计算中文和英文字符,一个中文等于两个字节
function getBytesCount(str) {
	if (str == null) {
		return 0;
	} else {
		return (str.length + str.replace(/[\u0000-\u00ff]/g, "").length);
	}
}

//----------------------------------------------
//打开流程图
function processImage(url) {
	openNewPage(url, true, 0.8, 0.7, 50, 50);
}

